﻿using System;
using System.ComponentModel;
using System.Data;
using ReflectionStudio.Core.Events;
using System.Windows;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for EditEventWindow.xaml
    /// </summary>
    public partial class UIWDECK : ViewBase
    {
       public  string CLSLIEFNR = "";
        public virtual void OnLIEFNRChg(string liefnr)
        {
            if (liefnr.Trim().Length < 8)
            {
                return;
            }
            if (dwMaster == null)
                return;
            dwMaster["WALIEFNR"] = liefnr;
            dwMaster["LSLIEFNR"] = liefnr;
        }
        public void Conver2EKK(object sender, RoutedEventArgs e)
        {
            if (TBDetail.Rows.Count == 0)
                return;
            Set = new DataSet();
            Set.Merge(TBDetail);
            string ls = TBDetail.Rows[0]["LSLIEFNR"].ToString();
            string FKRS = "E" + MV.year.Substring(3, 1);
            if (ls.Trim().Length == 0)
            {
                MessageBox.Show("请指定供应商");
                return;
            }
            PM["LSLIEFNR"] = ls;
            PM["WAEHRSL"] = TBDetail.Rows[0]["WAEHRSL"].ToString();
            PM["Set"] = Set;
            PM["FKRS"] = FKRS;
            EKAUF = "";
            EKAUF = TMV.VEK.EKAUTO(PM);
            TBDetail.Clear();
            CLSLIEFNR = "";
            base.SaveCommand(sender, e);
        }

    }
    public partial class UIWDECK
    { 

        #region ==LSLIEFNA===========
        public static readonly DependencyProperty LSLIEFNAProperty = DependencyProperty.Register("LSLIEFNA",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnLSLIEFNAChanged));
        public string LSLIEFNA
        {
            get
            {
                return (string)GetValue(LSLIEFNAProperty);
            }
            set
            {
                SetValue(LSLIEFNAProperty, value);
            }
        }
        private static void OnLSLIEFNAChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.LSLIEFNA = (string)e.NewValue;
            }
        }
        #endregion

        #region ==LIEFNR===========
        public static readonly DependencyProperty LIEFNRProperty = DependencyProperty.Register("LIEFNR",
        typeof(string), typeof(UIWDECK),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnLIEFNRChanged));
        public string LIEFNR
        {
            get
            {
                return (string)GetValue(LIEFNRProperty);
            }
            set
            {
                SetValue(LIEFNRProperty, value);
                OnLIEFNRChg(value);
            }
        }
        private static void OnLIEFNRChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.LIEFNR = (string)e.NewValue;
            }
        }
        
        #endregion
 
    }
}
